#ifndef __COMMON_H
#define __COMMON_H

#include "sys.h"

#define IS_AF(c)  ((c >= 'A') && (c <= 'F'))
#define IS_af(c)  ((c >= 'a') && (c <= 'f'))
#define IS_09(c)  ((c >= '0') && (c <= '9'))
#define ISVALIDHEX(c)  IS_AF(c) || IS_af(c) || IS_09(c)
#define ISVALIDDEC(c)  IS_09(c)
#define CONVERTDEC(c)  (c - '0')

#define CONVERTHEX_alpha(c)  (IS_AF(c) ? (c - 'A'+10) : (c - 'a'+10))
#define CONVERTHEX(c)   (IS_09(c) ? (c - '0') : CONVERTHEX_alpha(c))


uint16_t MBCrcCheck(uint8_t *puchMsg, uint16_t usDataLen);
uint8_t ReceCrcCheck(uint8_t *pbuff,uint8_t len);
uint32_t Str2Int(uint8_t *inputstr, int32_t *intnum);
char * mystrstr(char *str1, char *str2, int len);
#endif
